package com.wpam.scrabble.mobile.ui;

import com.wpam.scrabble.mobile.GameResources;

import android.graphics.Bitmap;
import android.graphics.LightingColorFilter;

public class LetterChangeSquare extends SquareBitmap {

	private boolean selected_;
	private LightingColorFilter selectFilter_;
	
	public LetterChangeSquare(int x, int y, int size) {
		
		super(x, y, size, SquareBitmap.BLANK);
		this.selected_ = false;
		this.selectFilter_ = new LightingColorFilter(0xFFFFFFFF, 0x000000FF);
	}
	
	public boolean amIHit(int x, int y) {
		
		if (x >= posX_ && x <= posX_ + size_ 
				&& y >= posY_ && y <= posY_ + size_)
			return true;
		return false;
	}
	
	public void toggle() {
		
		if (selected_) 
			setColorFilter(null);
		else
			setColorFilter(selectFilter_);
		this.selected_ = !selected_;
	}

	public boolean isSelected() {
		return selected_;
	}

	public void onResize(int posX, int posY, int tileSize) {

		this.posX_ = posX;
		this.posY_ = posY;
		this.size_ = tileSize;
		this.background_ = Bitmap.createScaledBitmap(GameResources.getInstance().getBlank(), size_, size_, true);
	}

}
